package com.appkubes.mall.admin.application.activity.activity.dao;

import com.appkubes.mall.admin.application.activity.activity.entity.dto.ActivityListDTO;
import com.appkubes.mall.core.dao.BaseMallActivityDao;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author: Lin Jiaming
 * @Date: 2020/3/5 17:28
 * @Description:
 */
@Mapper
@Repository
public interface ActivityDao extends BaseMallActivityDao {
    @Select("SELECT t1.activity_key,start_time,end_time,t4.goods_key,goods_id,main_pic,dtitle,coupon_total_num," +
            "coupon_receive_num,actual_price,commission_rate,two_hours_sales,shop_type,coupon_price,month_sales," +
            "shop_name,marketing_main_pic,coupon_link,item_link,promotion_text FROM mall_activity AS t1 " +
            "LEFT JOIN mall_activity_goods AS t2 ON t1.activity_key=t2.activity_key " +
            "LEFT JOIN mall_activity_source AS t3 ON t1.activity_key=t3.activity_key " +
            "LEFT JOIN mall_goods_taobao AS t4 ON t2.goods_key = t4.goods_key " +
            "WHERE t3.source_key='${sourceKey}' AND t3.source_tpe='SUPPLIER'")
    List<ActivityListDTO> activityList(@Param(value = "sourceKey") String sourceKey,
                                       Page pageInfo);

}
